package com.zhiwei.controller;

import com.zhiwei.pojo.Order;
import com.zhiwei.service.OrderService;
import com.zhiwei.vo.OrderInfo;
import com.zhiwei.vo.OrderTab;
import com.zhiwei.vo.PageResult;
import com.zhiwei.vo.SysResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@CrossOrigin
@RequestMapping("/order")
public class OrderController {
    @Autowired
    private OrderService orderService;
    @GetMapping("/thisMonth")
    public SysResult getThisMonth(){
        OrderTab[] orderTabs = orderService.getThisMonth();
        return SysResult.success(orderTabs);
    }
    @GetMapping("/billList")
    public SysResult getBillList(PageResult pageResult){
        PageResult orders = orderService.getBillList(pageResult);
        if (orders != null){
            return SysResult.success(orders);
        }
        return SysResult.fail();
    }
    @GetMapping("/info")
    public SysResult getOrderInfo(){
        OrderInfo orderInfo = orderService.getOrderInfo();
        if (orderInfo != null){
            return SysResult.success(orderInfo);
        }
        return SysResult.fail();
    }
}
